package cn.webrx.config;

import com.alibaba.druid.pool.DruidDataSource;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.stereotype.Component;

@Configuration
@Import(DruidConfig.class)
@MapperScan(basePackages = {"cn.webrx.mapper"},sqlSessionFactoryRef = "sf" )
@Component("cn.webrx.mapper")
@Slf4j
public class SpringConfig {

    @Bean("sf")
    public SqlSessionFactoryBean sqlSessionFactoryBean(DruidDataSource ds){
        var sf = new SqlSessionFactoryBean();
        sf.setDataSource(ds);
        return sf;
    }

}
